import java.util.HashMap;
import java.util.List;

class Employee {
    public int id;
    public int importance;
    public List<Integer> subordinates;
};

public class num690 {
    public int getImportance(List<Employee> employees, int id) {
        HashMap<Integer,Employee> info = new HashMap<Integer, Employee>();
        for(Employee e : employees) {
            info.put(e.id,e);
        }
        return dfs(info,id);
    }

    private int dfs(HashMap<Integer,Employee> info, int id) {
        Employee emp = info.get(id);
        int sum = emp.importance;
        for(int i : emp.subordinates) {
            sum += dfs(info,i);
        }
        return sum;
    }
}
